package com.ld.rightsSystem.mapper;

import com.ld.rightsSystem.pojo.TrUserRole;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;
@Repository
public interface TrUserRoleRepository extends JpaRepository<TrUserRole,Long> {
    @Transactional
    int deleteTrUserRoleByUserId(@Param("userId")Long userId);

    @Query(value = "select role_id from auth.tr_user_role where user_id=:userId",nativeQuery = true)
    List<Long> findRoleIdsByUserId(@Param("userId")Long userId);
}
